public class Test1 {
    public static void main(String[] args) {
         int[] arr = {10 , 15 , 20} ;
        System.out.println(numDecodings("10"));
    }
    public static int numDecodings(String s) {
        int len = s.length() ;
        char[] chs = s.toCharArray() ;
        int[] arr = new int[len];
        for(int i=0;i<len ;i++){
            arr[i] = chs[i]-'0';
        }
        if(len <= 1){
            return arr[0]==0?0:1 ;
        }
        if(arr[0]==0 || arr[1]==0&&arr[0]>2){
            return 0 ;
        }
        int[] dp = new int[len];
        dp[0] = arr[0]==0?0:1 ;
        dp[1] = (arr[1]==0?0:1) + ((arr[0]*10+arr[1]>=10)&&(arr[0]*10+arr[1]<=26)?1:0);

        for(int i=2 ; i<len ; i++){
            int tmp = arr[i];
            int prev = arr[i-1];
            int one = (tmp==0?0:dp[i-1]) ;
            int two = (prev==0?0: (prev*10+tmp>=10&&prev*10+tmp<=26?dp[i-2]:0));
            dp[i]= one+two ;
            if(dp[i] == 0){
                return 0 ;
            }
        }
        return dp[len-1];
    }


    public static int minCostClimbingStairs(int[] cost) {
        int len = cost.length ;
        int[] sum = new int[len];
        sum[0] = cost[0] ;
        sum[1] = cost[1] ;
        for(int i = 2 ; i < len ; i ++){
            sum[i] = cost[i]+(sum[i-1]<sum[i-2]?sum[i-1]:sum[i-2]) ;
        }
        return sum[len-1] < sum[len-2]?sum[len-1]:sum[len-2] ;
    }
}
